package ms.unicorn.dsl;

import ms.unicorn.UnicornService;


import org.eclipse.core.runtime.Status;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class DslPluginActivator extends AbstractUIPlugin implements IStartup {

	// The plug-in ID
		public static final String PLUGIN_ID = "ms.unicorn.dsl"; //$NON-NLS-1$

		// The shared instance
		private static DslPluginActivator plugin;
		
		/**
		 * The constructor
		 */
		public DslPluginActivator() {
		}

		/*
		 * (non-Javadoc)
		 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
		 */
		public void start(BundleContext context) throws Exception {
			super.start(context);		
			plugin = this;
			ms.unicorn.dsl.utils.ReflectionUtil.registerBundle(PLUGIN_ID);
			
			// register subscribers
		}

		/*
		 * (non-Javadoc)
		 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
		 */
		public void stop(BundleContext context) throws Exception {
			plugin = null;
			super.stop(context);
		}

		/**
		 * Returns the shared instance
		 *
		 * @return the shared instance
		 */
		public static DslPluginActivator getDefault() {
			return plugin;
		}

		@Override
		public void earlyStartup() {
		
		}
		
		public void log(int severity,  String format, Object... args) {
			getLog().log(new Status(severity, PLUGIN_ID, Status.OK, String.format(format, args), null));
		}

}
